#include <51func.h>
void handler(int signum){
    printf("before signum = %d\n", signum);
    sleep(5);
    printf("after signum = %d\n", signum);
    sigset_t pending;
    sigpending(&pending);
    if(sigismember(&pending,SIGINT)){
        printf("2 is pending!\n");
    }
    if(sigismember(&pending,SIGQUIT)){
        printf("3 is pending!\n");
    }
}
int main(int argc, char *argv[])
{
    //signal(SIGINT,handler);//注册了2号信号
    struct sigaction act;
    memset(&act,0,sizeof(act));
    act.sa_handler = handler;
    act.sa_flags = SA_RESTART;
    sigemptyset(&act.sa_mask);
    sigaddset(&act.sa_mask,SIGQUIT);
    // sa_mask 额外临时屏蔽
    sigaction(SIGINT,&act,NULL);
    char buf[4096] = {0};
    ssize_t sret = read(STDIN_FILENO,buf,sizeof(buf));
    printf("sret = %ld, buf = %s\n", sret, buf);
    return 0;
}

